<?php
$config_id=$_REQUEST['config_id'];
include("connection.php");
	$query = mysql_query("SELECT * from `configuration` WHERE idConfiguration='$config_id'") ;	
	$row=mysql_fetch_array($query);
	$dep_type=$row['dep_type'];
	$arr_type=$row['arr_type'];
	$dep=$row['dep_code'];
	$arr=$row['arr_code'];	

    
function get_name($type,$code)
{
	switch($type)
	{
		case "1":
		$query = mysql_query("SELECT `name`,`airport_code` from `airport_code` WHERE airport_code='$code' ORDER By rank") ;
		while($row=mysql_fetch_array($query))
		{
			echo  "<option value='".$row["airport_code"]."'>".$row["name"]."</option>";
		}
		break;
		case "2":
		$query = mysql_query("SELECT `name`,`airport_code` from `airport_code`  WHERE state_code='$code' ORDER By rank") ;
		while($row=mysql_fetch_array($query))
		{
			echo "<option value='".$row["airport_code"]."'>".$row["name"]."</option>";
		}
		break;
		case "3":
		$query = mysql_query("SELECT `name`,`airport_code` from `airport_code`  WHERE country_code='$code' ORDER By rank") ;
		while($row=mysql_fetch_array($query))
		{
			echo  "<option value='".$row["airport_code"]."'>".$row["name"]."</option>";
		}
		break;
		case "4":
		$query = mysql_query("SELECT  `name`,`airport_code` from `airport_code` WHERE region_code='$code' ORDER By rank") ;            
		while($row=mysql_fetch_array($query))
		{
			echo "<option value='".$row["airport_code"]."'>".$row["name"]."</option>";
		}
		return $row[0];
		break;
		case "5":
		$query=mysql_query("SELECT `name`,`airport_code` from `airport_code` order by `rank`");
		while($row=mysql_fetch_array($query))
		{
			echo "<option value='".$row["airport_code"]."'>".$row["name"]."</option>";
		}
		return $row[0];
		break;
		

	}
	
}
?>


<form id="test_request" method="post" action="" class="test_request">
  <table width="422" border="0" align="center" cellpadding="4" cellspacing="1">
    <tr>
      <td colspan="2" bgcolor="#EEEEEE"><strong>Test Request</strong></td>
    </tr>
    <tr>
      <td colspan="2" align="center" bgcolor="#f5f5f5"><input type="text" name="request_id" value="<?php echo $_REQUEST['request_id'];?>" style="display:none;" />
        <input type="radio" name="search_type"  value="RT" checked="checked" />
        Round Trip
        <input type="radio" name="search_type"  value="OW" />
      One Way</td>
    </tr>
    <tr>
      <td width="92" bgcolor="#f5f5f5">From</td>
      <td width="311" bgcolor="#f5f5f5"><label>
        <select name="origin_code" id="select" style="width:300px;" class="required">
        <?php
        get_name($dep_type,$dep)
        ?>
        </select>
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">To</td>
      <td bgcolor="#f5f5f5"><select name="dest_code" id="select2" style="width:300px;" class="required">
              <?php
        get_name($arr_type,$arr)
        ?>
      </select></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">Dep Date</td>
      <td bgcolor="#f5f5f5"><label>
        <input type="text" name="dep_date" id="start-date" class="date_pick required" style="float:left">
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">Retun Date</td>
      <td bgcolor="#f5f5f5"><input type="text" name="ret_date" id="end-date" class="date_pick required" style="float:left"></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">Adult</td>
      <td bgcolor="#f5f5f5"><label>
        <select name="num_adt" id="select3" class="required">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">Child</td>
      <td bgcolor="#f5f5f5"><label>
        <select name="num_chd" id="select4 " class="required">
          <option value="0">0</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">Infant</td>
      <td bgcolor="#f5f5f5"><select name="num_inf" id="num_inf" class="required">
        <option value="0">0</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
      </select></td>
    </tr>
    <tr>
      <td bgcolor="#f5f5f5">Class</td>
      <td bgcolor="#f5f5f5"><label>
        <select name="cab_cla" id="select5" class="required">
          <option value="E">Economy</option>
          <option value="B">Business</option>
          <option value="F">First</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#f5f5f5" align="center"><label>
        <input type="submit" name="button" id="button" value="Submit">
      </label></td>
    </tr>
  </table>
</form>
<?php
mysql_close($con);
?>
